﻿#region Using Statements
using System.IO;
using DirectZZT.Shared.World.Objects;
#endregion

namespace DirectZZT.Shared.World
{
    /// <summary>
    /// Defines a means for a type that loads/saves a world.
    /// </summary>
    public interface IWorldSerializer
    {
        /// <summary>
        /// Returns the extension of the file that this serializer creates.
        /// </summary>
        string Extension { get; }
        /// <summary>
        /// Returns the extension of the save file that this serializer creates.
        /// </summary>
        string SaveExtension { get; }

        /// <summary>
        /// Called before the world gets loaded, to see whether or not the world encapsulated in the given stream is even valid for this serializer.
        /// </summary>
        /// <param name="stream">The stream to load the world from.</param>
        /// <returns>Whether or not the stream is valid for this serializer.</returns>
        bool IsValid(Stream stream);
        /// <summary>
        /// Loads a world from the given stream.
        /// </summary>
        /// <param name="stream">The stream to load the world from.</param>
        /// <param name="destination">The <see cref="World"/> instance to load into.</param>
        /// <param name="options">Provides the options that were used to load the world.</param>
        void Load(Stream stream, World destination, WorldDeserializeOptions options);
        /// <summary>
        /// Saves a world to the given stream.
        /// </summary>
        /// <param name="world">The world to save.</param>
        /// <param name="stream">The stream to save the world to.</param>
        /// <param name="options">Provides the options that shall be used to save the world.</param>
        void Save(World world, Stream stream, WorldSerializeOptions options);
    }
}
